async function getServerSideProps(context) {
const res = await fetch('http://localhost:3000/api' + context.resolvedUrl);
const data = await res.json();
return { props: { data } };
}
function MidSection(props) {
return (
{props.children}
);
}
function MainContentContainer(props) {
return (
{props.children}
);
}
function BreadCrumbTrail(props) {
const pathArray = props.pathArray;
const recursion = (acc) => {
if (acc.length === pathArray.length) {
return acc;
} else {
const subArray = pathArray.slice(0, acc.length + 1);
const breadCrumb = {
name: pathArray[acc.length],
href: '/' + subArray.join('/'),
};
const newAcc = acc.concat([breadCrumb]);
return recursion(newAcc);
}
};
const breadCrumbs = recursion([]);
return (
);
}
function PageSubstance(props) {
const data = props.data;
switch (data.resultType) {
case 'treeContents':
const treeContents = data.resultContent.trees.concat(data.resultContent.blobs);
return (
{treeContents.map((item) => (
- {item}
))}
);
break;
case 'textBlob':
return (
{data.resultContent}
);
break;
case 'binaryBlob':
return (
Binary content cannot be displayed.
);
break;
case 'error':
return (
Error:
{data.resultContent}
);
break;
}
}
function Main({ data }) {
return (
);
}
export { getServerSideProps };
export default Main;